import request from '../utils/request';
import {stringify} from 'qs';
import config from '../config';
import pca from '../pca';

export function getCms(params) {
  return request(`${config.apiPrefix}/cms/${params}`);
}

export function createProject(params) {
  return request({
    url: `${config.apiPrefix}/projects`,
    method: 'POST',
    data: params,
  });
}

export function getRecomProjects(params) {
  return request(`${config.apiPrefix}/projects_get_recom?${stringify(params)}`);
}

export function getProjectsByIds(params) {
  return request(`${config.apiPrefix}/projects_get_by_ids?${stringify(params)}`);
}

export function searchProjects(params) {
  return request(`${config.apiPrefix}/projects_search?${stringify(params)}`);
}

export function getProject(params) {
  return request(`${config.apiPrefix}/projects/${params}`);
}

export function getFundings(params) {
  return request(`${config.apiPrefix}/fundings?${stringify(params)}`);
}

export function getFunding(params) {
  return request(`${config.apiPrefix}/fundings/${params}`);
}

export function getServices(params) {
  return request(`${config.apiPrefix}/services?${stringify(params)}`);
}

export function getService(params) {
  return request(`${config.apiPrefix}/services/${params}`);
}

export function getPca() {
  // return request(`${config.addressListApi}${config.qqMapKey}`);
  return pca;
}

export function register(params) {
  return request({
    url: `${config.apiPrefix}/customers?code=${params.code}`,
    method: 'POST',
    data: params,
  });
}

export function login(params) {
  return request({
    url: `${config.apiPrefix}/customers_login?code=${params.code}`,
    method: 'POST',
    data: params,
  });
}

export function getCustomer(params) {
  return request(`${config.apiPrefix}/projects/${params}`);
}

export function sms(params) {
  return request(`${config.apiPrefix}/sms?${stringify(params)}`);
}